package com.srwl.mytx.domain;

import androidx.annotation.NonNull;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class Comment implements Cloneable {
    private String id;

    private String topicId;

    private String parentId;

    private Integer topicType;

    private String content;

    private String fromUid;

    private String fromNick;

    private String fromAvatar;

    private String toUid;

    private String toNick;

    private String toAvatar;

    private Integer status;

    private Integer type;

    private Date created;

    //子评论数量
    private int childSize;

    //我对该评论是否已经点过赞
    private boolean hadPraise;
    //该评论被点赞的数量
    private int praiseSize;
    private boolean displayChildComments;
    private List<Comment> childCommentList;
    //父评论
    private Comment parentComment;
    //标记是否还可以加载更多子评论
    private boolean haveMoreChildComment;
    //请求子评论的页数
    private int nextPage;


    public Comment(String id, String topicId, String parentId, Integer topicType, String content, String fromUid, String fromNick, String fromAvatar, Integer status, Integer type, Integer childSize, Integer praiseSize, String toUid, String toNick, String toAvatar, Date created) {
        this.id = id;
        this.topicId = topicId;
        this.parentId = parentId;
        this.topicType = topicType;
        this.content = content;
        this.fromUid = fromUid;
        this.fromNick = fromNick;
        this.fromAvatar = fromAvatar;
        this.status = status;
        this.type = type;
        this.childSize = childSize;
        this.praiseSize = praiseSize;
        this.toUid = toUid;
        this.toNick = toNick;
        this.toAvatar = toAvatar;
        this.created = created;
    }

    public Comment() {
        super();
    }

    @NonNull
    @Override
    public Object clone() throws CloneNotSupportedException {
        return super.clone();
    }


    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id == null ? null : id.trim();
    }

    public String getTopicId() {
        return topicId;
    }

    public void setTopicId(String topicId) {
        this.topicId = topicId == null ? null : topicId.trim();
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public Integer getTopicType() {
        return topicType;
    }

    public void setTopicType(Integer topicType) {
        this.topicType = topicType;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content == null ? null : content.trim();
    }

    public String getFromUid() {
        return fromUid;
    }

    public void setFromUid(String fromUid) {
        this.fromUid = fromUid == null ? null : fromUid.trim();
    }

    public String getFromNick() {
        return fromNick;
    }

    public void setFromNick(String fromNick) {
        this.fromNick = fromNick == null ? null : fromNick.trim();
    }

    public String getFromAvatar() {
        return fromAvatar;
    }

    public void setFromAvatar(String fromAvatar) {
        this.fromAvatar = fromAvatar == null ? null : fromAvatar.trim();
    }

    public String getToUid() {
        return toUid;
    }

    public void setToUid(String toUid) {
        this.toUid = toUid == null ? null : toUid.trim();
    }

    public String getToNick() {
        return toNick;
    }

    public void setToNick(String toNick) {
        this.toNick = toNick == null ? null : toNick.trim();
    }

    public String getToAvatar() {
        return toAvatar;
    }

    public void setToAvatar(String toAvatar) {
        this.toAvatar = toAvatar == null ? null : toAvatar.trim();
    }

//    public int getChildSize() {
//        return childSize;
//    }
//
//    public void setChildSize(int childSize) {
//        this.childSize = childSize;
//    }


    public int getChildSize() {
        return childSize;
    }

    public void setChildSize(int childSize) {
        this.childSize = childSize;
    }

    public void addChildSize() {
        this.childSize ++;
    }

    public boolean isHadPraise() {
        return hadPraise;
    }

    public void setHadPraise(boolean hadPraise) {
        this.hadPraise = hadPraise;
    }

    public int getPraiseSize() {
        return praiseSize;
    }

    public void setPraiseSize(int praiseSize) {
        this.praiseSize = praiseSize;
    }

    public boolean isDisplayChildComments() {
        return displayChildComments;
    }

    public void setDisplayChildComments(boolean displayChildComments) {
        this.displayChildComments = displayChildComments;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public List<Comment> getChildCommentList() {
        if (childCommentList == null) {
            childCommentList = new ArrayList<>();
        }
        return childCommentList;
    }

    public void addChildCommentList(List<Comment> childComments) {
        if (childCommentList == null) {
            childCommentList = new ArrayList<>();
        }
        childCommentList.addAll(childComments);
    }

    public void addChildComment(Comment comment) {
        if (childCommentList == null) {
            childCommentList = new ArrayList<>();
        }
        //插入到第一条
        childCommentList.add(0, comment);
    }

    public Comment getParentComment() {
        return parentComment;
    }

    public void setParentComment(Comment parentComment) {
        this.parentComment = parentComment;
    }


    public boolean isHaveMoreChildComment() {
        return haveMoreChildComment;
    }

    public void setHaveMoreChildComment(boolean haveMoreChildComment) {
        this.haveMoreChildComment = haveMoreChildComment;
    }

    public int getNextPage() {
        return nextPage;
    }

    public void setNextPage(int nextPage) {
        this.nextPage = nextPage;
    }

    public Date getCreated() {
        return created;
    }

    public void setCreated(Date created) {
        this.created = created;
    }
}